package com.opennews.openplatform.controller;

import com.opennews.openplatform.service.ProductService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequiredArgsConstructor
@RestController
@RequestMapping("/products")
public class ProductController {
    private final ProductService productService;

    @GetMapping
    public ResponseEntity<List<Map<String, Object>>> list(@RequestParam List<String> ids) {
        List<Map<String, Object>> result = productService.list(ids);

        return ResponseEntity.ok(result);
    }

    @PostMapping
    public ResponseEntity testTransaction() {
        productService.testTransaction();
        return ResponseEntity.ok().build();
    }
}
